﻿<%@ Page Title="Display" Language="C#" AutoEventWireup="true" CodeBehind="Display.aspx.cs" Inherits="TB.Site.Display" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title></title>
</head>
<body>

    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

	<form id="form1" runat="server">
	<div>
	<h1> random message:</h1>

&nbsp;<textarea id="TextArea1" cols="20" dir="ltr" name="S1" rows="2" runat="server"></textarea> 
<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
		by:&nbsp;&nbsp;
<input type="text" id="Author" runat="server" /><br />
		<br />
	<br />

	<asp:Label id="label1" runat="server" />
	<br />

	<div id="fb-root"></div>

<script type="text/javascript">
	var msgsList = <%= msgsList %>;
	var pagePath = window.location.pathname;
	
	//parses the list
	function parseList(pos,list)
	{	
	if  (pos < list.length)
	{
			var obj = list[pos];
			TextArea1.value = obj.Content;
			Author.value = obj.Author;
			//$("fbLike").att("href") = pagePath + '?' + obj.Guid;
			$("#fb_like").attr({src : "http://www.facebook.com/plugins/like.php?href=" + window.location.href +"?id="+ obj.Guid});
            setTimeout(function(){parseList(++pos,list)}, 5000);
	}
	else
	{
	//PageMethod('RefillMessages', [], AjaxSucceeded, AjaxFailed);
    WebMethod('RefillMessages', [], AjaxSucceeded, AjaxFailed);
	}
	}
		
	parseList(0,msgsList);

//--------------------------------------------------------------------------+
// jQuery call AJAX Page Method                                             |
//--------------------------------------------------------------------------+
function PageMethod(fn, paramArray, successFn, errorFn) {
	var pagePath = window.location.href;//window.location.pathname;
	
	
	
	$.ajax({
		type: 'POST',
		url: pagePath + '/' + fn,
		contentType: 'application/json; charset=utf-8',
		data: '{}',
		dataType: 'json',
		success: successFn,
		error: errorFn
	});
}

//--------------------------------------------------------------------------+
// jQuery call AJAX WEB Method                                              |
//--------------------------------------------------------------------------+
 
function WebMethod(fn, paramArray, successFn, errorFn) {
 
	//----------------------------------------------------------------------+
	// Call the WEB method                                                  |
	//----------------------------------------------------------------------+
	$.ajax({
		type: 'POST',
		url: '/ClientServices/MessagesService.asmx' + '/' + fn,
		contentType: 'application/json; charset=utf-8',
		data: '{}',
		dataType: 'json',
		success: successFn,
		error: errorFn
	});
}

//---------------------------------------------+
// jQuery AJAX Call Succeeded.                 |
//---------------------------------------------+
function AjaxSucceeded(result) {
	//msgsList = result;
	parseList(0,result);
}
 
//------------------------------------------------+
// jQuery AJAX Call FAILED.                       |
//------------------------------------------------+
function AjaxFailed(result) {
	alert('SERVICE Failed : ' + result.d);
}
 



</script>

<iframe id=fb_like src="http://www.facebook.com/plugins/like.php;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:px"></iframe>

<%--
<script>
	window.fbAsyncInit = function () {
		FB.init({
			appId: 'YOUR_APP_ID', // App ID
			channelURL: '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
			status: true, // check login status
			cookie: true, // enable cookies to allow the server to access the session
			oauth: true, // enable OAuth 2.0
			xfbml: true  // parse XFBML
		});

		// Additional initialization code here
	};

	// Load the SDK Asynchronously
	(function (d) {
		var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
		js = d.createElement('script'); js.id = id; js.async = true;
		js.src = "//connect.facebook.net/en_US/all.js";
		d.getElementsByTagName('head')[0].appendChild(js);
	} (document));
</script>


<fb:like id=fbLike href=FBlink layout="standard" show-faces="true" width="450" action="like" colorscheme="light" />

--%>

	</div>

	</form>
</body>
</html>
